package HomeWork.Chapter04;

/**
 * Enjoy programming!!!
 * Time: 2021/11/27 -  13:42
 */
import java.util.*;

public class LeapYear{

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        int year = input.nextInt();
        int month = input.nextInt();

        MyDate a = new MyDate(year, month);

        System.out.println(a.isLeapYear());
        System.out.println(a.getMonthDay());
    }

}
class MyDate{
    int year;
    int month;

    public MyDate(int y, int m){
        year = y;
        month = m;
    }
    public boolean isLeapYear(){
        return (0 == year % 4 && year % 100 != 0) || 0 == year % 400;
    }

    public int getMonthDay(){
        if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12){
            return 31;
        }
        else if (month == 4 || month == 6 || month == 8 || month == 11 ){
            return 30;
        }
        else if (month == 2){
            return isLeapYear() ? 29 : 28;
        }
        else {
            return -1;
        }
    }
}
